#include "updateprofileresponse.h"


#include <QVariant>
#include <QDebug>


namespace Profile {

UpdateProfileResponse::UpdateProfileResponse(QObject *parent) :
    JSONResponse(parent)
    ,m_isUpdateProfileSuccess(false)
{
}



void UpdateProfileResponse::parse(const QVariant &data)
{
    //Q_UNUSED(data);
    //qDebug() << "Update profile:";

    if (data.type() != QVariant::Map) {
        setError(Response::Property, "The field of \"map\" isn't a map");
        return;
    }

    QVariantMap map = data.toMap();
    if (!map.contains("key")) {
        setError(Response::Property, "The field of \"key\" is missing");
        return;
    }

    if (!map.contains("userIdFrom")) {
        setError(Response::Property, "The field of \"userIdFrom\" is missing");
        return;
    }

    if (!map.contains("type")) {
        setError(Response::Property, "The field of \"type\" is missing");
        return;
    }

    if (!map.contains("createdTime")) {
        setError(Response::Property, "The field of \"createdTime\" is missing");
        return;
    }

    if (!map.contains("comment")) {
        setError(Response::Property, "The field of \"comment\" is missing");
        return;
    }

    if (!map.contains("totalCmt")) {
        setError(Response::Property, "The field of \"totalCmt\" is missing");
        return;
    }

    if (!map.contains("numLike")) {
        setError(Response::Property, "The field of \"numLike\" is missing");
        return;
    }

    m_isUpdateProfileSuccess = true;
}

} // namespace Profile
